
import { createRouter, createWebHistory } from 'vue-router';
import Login from '../components/Login.vue';
import Register from '../components/Register.vue';
import CusLayout from '../components/customer/CusLayout.vue';
import CusShop from '../components/customer/CusShop.vue';
import CusOrders from '../components/customer/CusOrder.vue';
import CusAccount from '../components/customer/CusAccount.vue';
import CusInfoEditor from '../components/customer/cus_account_edit/CusInfoEditor.vue';
import CusPwdEditor from '../components/customer/cus_account_edit/CusPwdEditor.vue';
import BusLayout from '../components/business/BusLayout.vue';
import BusProdList from '../components/business/BusProdList.vue';
import BusOrder from '../components/business/BusOrder.vue';
import BusAccount from '../components/business/BusAccount.vue';
import AdminLayout from '../components/admin/AdminLayout.vue';

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/system',
    name: 'AdminLayout',
    component: AdminLayout,
    children: [
      {
        path: 'cus_manager',
        name: 'AdminCusManager',
        component: () => import('../components/admin/accounts_manage/CusAccountsManager.vue'),
      },
      {
        path: 'bus_manager',
        name: 'AdminBusManager',
        component: () => import('../components/admin/accounts_manage/BusAccountsManager.vue'),
      },
      {
        path: 'account_editor',
        name: 'AccountEditor',
        component: () => import('../components/admin/accounts_manage/AccountEditor.vue'),
      },
      {
        path: 'accounts_statistics',
        name: 'AccountsStatistics',
        component: () => import('../components/admin/accounts_manage/AccountsStatistics.vue'),
      },
      {
        path: 'product_manager',
        name: 'AllProdManager',
        component: () => import('../components/admin/product_manage/AllProdManager.vue'),
      },
      {
        path: 'product_statistics',
        name: 'ProductStatistics',
        component: () => import('../components/admin/product_manage/ProdStatistics.vue'),
      },
      {
        path: 'orders_manager',
        name: 'AllOrdersManager',
        component: () => import('../components/admin/orders_manage/AllOrdersManager.vue'),
      },
      {
        path: 'orders_statistics',
        name: 'OrdersStatistics',
        component: () => import('../components/admin/orders_manage/OrdersStatistics.vue'),
      },
      {
        path: 'infoEdit',
        name: 'AdminInfoEditor',
        component: () => import('../components/admin/AdminInfoEditor.vue'),
      }
    ]
  },
  {
    path: '/customer',
    name: 'CustomerLayout',
    component: CusLayout,
    children: [
      {
        path: 'shop',
        children: [
          {
            path: '',
            component: CusShop,
          },
          {
            path: 'purchase',
            component: () => import('../components/customer/cus_purchase/CusPurchase.vue'),
          }
        ]
      },
      {
        path: 'orders',
        component: CusOrders,
      },
      {
        path: 'account',
        // component: CusAccount,
        children: [
          {
            path: '',
            name: 'InfoViewer',
            component: CusAccount,
          },
          {
            path: 'infoEdit',
            name: 'InfoEditor',
            component: CusInfoEditor,
          },
          {
            path: 'pwdEdit',
            name: 'PwdEditor',
            component: CusPwdEditor
          }
        ]
      },
    ]
  },
  {
    path: '/business',
    name: 'BusinessLayout',
    component: BusLayout,
    children: [
      {
        path: 'myProd',
        // component: BusProdList,
        children: [
          {
            path: '',
            name: 'MyProd',
            component: BusProdList,
          },
          {
            path: 'create',
            name: 'CreateProd',
            component: () => import('../components/business/bus_prod_manage/BusCreateProd.vue')
          },
          {
            path: 'edit',
            name: 'EditProd',
            component: () => import('../components/business/bus_prod_manage/BusEditProd.vue'),
          },
        ]
      },
      {
        path: 'orders',
        children: [
          {
            path: '',
            name: 'BusOrders',
            component: BusOrder,
          },
          {
            path: 'manager',
            name: 'BusOrderManager',
            component: () => import('../components/business/bus_order_manage/BusOrderManager.vue'),
          },
        ]
      },
      {
        path: 'account',
        children: [
          {
            path: '',
            name: 'BusInfoViewer',
            component: BusAccount,
          },
          {
            path: 'infoEdit',
            name: 'BusInfoEditor',
            component: () => import('../components/business/bus_account_edit/BusInfoEditor.vue'),
          },
          {
            path: 'pwdEdit',
            name: 'BusPwdEditor',
            component: () => import('../components/business/bus_account_edit/BusPwdEditor.vue'),
          }
        ]
      }
    ]
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

export default router;
